import service from "../../utils/request";
import qs from "qs";
// 登录
export const teacherLogin = async (data: any): Promise<string> => {
  return await service.post("/teacher/login", data);
};
// 注册
export const teacherRegister = async (data: any): Promise<string> => {
  // 使用 qs.stringify 将对象转换为 x-www-form-urlencoded 格式
  const formData = qs.stringify({
    teaName: data.teaName,
    staffId: data.staffId,
    teaSex: data.teaSex,
    teaEmail: data.teaEmail,
    teaPhone: data.teaPhone,
    password: data.password,
    checkPassword: data.checkPassword, // 如果后端也需要这个字段的话
  });

  return await service.post("/teacher/register", formData, {
    headers: {
      "Content-Type": "application/x-www-form-urlencoded", // 设置正确的 Content-Type
    },
  });
};
// 登出
export const teacherLayOut = async () => {
  return await service.get("/teacher/logout");
};
// 教师信息
export const teacherInfo = async (): Promise<UserInfo> => {
  return await service.get("/teacher/info");
};
// 管理班级
export const teacherClass = async (): Promise<string[]> => {
  return await service.get("/teacher/class");
};
// 修改教师信息
export const updateTeacherInfo = async (data: any) => {
  return await service.put(`teacher/update`, data);
};
// 获取学习进度
export const getStudyStatus = async (data: any): Promise<any> => {
  return await service.post(`/studentManage/studyStatus?studentId=${data.studentId}`, data);
};
export interface UserInfo {
  /* */
  authority: number;

  /* */
  headshot: string;

  /* */
  id: number;

  /* */
  password: string;

  /* */
  staffId: string;

  /* */
  teaEmail: string;

  /* */
  teaName: string;

  /* */
  teaPhone: string;

  /* */
  teaSex: number;
}
